package acwing_01;

import java.io.*;
import java.util.*;

public class _795_前缀和 {
	// 快读快写
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
	static int N = 100010;
	static int n,m;
	static int arr[] = new int[N];
	static int sum[] = new int[N];
	static int l;
	static int r;
	public static void main(String[] args) throws IOException{
		
		StringTokenizer st = new StringTokenizer(br.readLine());
		n = Integer.parseInt(st.nextToken());
		m = Integer.parseInt(st.nextToken());
		
		st = new StringTokenizer(br.readLine());
		for(int i = 1; i <= n; i++) {
			// 边读值边计算前缀和
			arr[i] = Integer.parseInt(st.nextToken());
			sum[i] = sum[i-1] + arr[i];
		}
		
		
		for(int i = 0; i < m; i++) {
			st = new StringTokenizer(br.readLine());
			l = Integer.parseInt(st.nextToken());
			r = Integer.parseInt(st.nextToken());
			// 计算l-r的和，需要r减去l左边的元素 l-1
			int s = sum[r] - sum[l-1];
			bw.write(s + "\n");

		}
		
		bw.flush();
		br.close();
		bw.close();
		
		
	}
}
